package limeirafol.gui.financeiro;

import javax.swing.SwingConstants;
import limeirafol.Global;
import lbframework.bean.internalFrame.LBInternalFrame;
import lbframework.bean.mdiFrame.LBMdiFrame;
import lbframework.bean.table.LBColumnTable;
import lbframework.classe.Util;
import lbframework.classe.LBException;

public class ContasPagarCadastroGUI extends LBInternalFrame {

    int parcelaAtual = 1;
    int totalParcelas = 1;

    public ContasPagarCadastroGUI(LBMdiFrame i_mdiFrame) throws Exception {
        super(i_mdiFrame);
        initComponents();
        centralizarForm();

        cboNumeroParcelas.setTabela("numeroparcelas");
        cboNumeroParcelas.setCampoOrdenacao("id", "");
        cboNumeroParcelas.carregar();
        lblDiaAtraso.setEnabled(false);
        lblDiaAdiantamento.setEnabled(false);
        txtPorcentagemAtraso.setEnabled(false);
        txtPorcentagemDesconto.setEnabled(false);
        lblAte.setEnabled(false);
        txtDataDesconto.setEnabled(false);
        txtPorcentagemDesconto.setObrigatorio(false);
        txtDataDesconto.setObrigatorio(false);
        txtPorcentagemAtraso.setObrigatorio(false);

        cboSituacao.setTabela("situacaopagamento");
        cboSituacao.carregar();
        cboSituacao.setEnabled(false);

        txtDataLancamento.setText(Global.getDataProcessamento());

        txtDataVencimento.requestFocusLater();

        txtDataVencimento.setConsultaData(Global.class.getMethod("getDataProcessamento"));

    }

    @Override
    public void incluir() throws Exception {
        verificarAlteracaoTela();
        
        txtDataVencimento.setText("");
        txtDescricao.setText("");
        txtDataLancamento.setText(Global.getDataProcessamento());
        cboNumeroParcelas.setId(1);
        cboNumeroParcelas.setId(1);
        chkAtraso.setSelected(false);
        chkDesconto.setSelected(false);
        txtPorcentagemAtraso.setEnabled(false);
        lblDiaAtraso.setEnabled(false);
        txtPorcentagemAtraso.setText("");
        txtPorcentagemDesconto.setEnabled(false);
        lblDiaAdiantamento.setEnabled(false);
        txtPorcentagemDesconto.setText("");
        txtValorDocumento.setText("");
        tblParcelas.clear();

        txtDataVencimento.requestFocusLater();

        getEstadoTelaInicial();
    }

    public void carregarParcelas() throws Exception {
        LBColumnTable[] colunas = new LBColumnTable[]{
            new LBColumnTable("Data", 70, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Valor", 70, true, SwingConstants.LEFT, false, null)
        };

        Object[][] dados = new Object[totalParcelas][colunas.length];

        int i = 0;

        for (i = 0; i < totalParcelas; i++) {
            dados[i][0] = Util.dateAdd(txtDataVencimento.getText(), "m", i);
            dados[i][1] = txtValorDocumento.getText();
        }
        tblParcelas.setModel(dados, colunas);
        tblParcelas.requestFocus();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        vRToolBarPadrao1 = new lbframework.bean.toolBarPadrao.LBToolBarPadrao();
        vRToolBarPadrao2 = new lbframework.bean.toolBarPadrao.LBToolBarPadrao(this);
        vRPanel1 = new lbframework.bean.panel.LBPanel();
        vRLabel1 = new lbframework.bean.label.LBLabel();
        vRLabel2 = new lbframework.bean.label.LBLabel();
        vRLabel3 = new lbframework.bean.label.LBLabel();
        vRLabel4 = new lbframework.bean.label.LBLabel();
        vRLabel5 = new lbframework.bean.label.LBLabel();
        txtDataLancamento = new lbframework.bean.textField.LBTextField();
        txtDataVencimento = new lbframework.bean.textField.LBTextField();
        txtDescricao = new lbframework.bean.textField.LBTextField();
        txtValorDocumento = new lbframework.bean.textField.LBTextField();
        cboSituacao = new lbframework.bean.comboBox.LBComboBox();
        vRLabel6 = new lbframework.bean.label.LBLabel();
        cboNumeroParcelas = new lbframework.bean.comboBox.LBComboBox();
        vRLabel7 = new lbframework.bean.label.LBLabel();
        txtParcela = new lbframework.bean.textField.LBTextField();
        vRPanel3 = new lbframework.bean.panel.LBPanel();
        vRButton1 = new lbframework.bean.button.LBButton();
        vRButton2 = new lbframework.bean.button.LBButton();
        vRPanel2 = new lbframework.bean.panel.LBPanel();
        chkAtraso = new lbframework.bean.checkBox.LBCheckBox();
        txtPorcentagemAtraso = new lbframework.bean.textField.LBTextField();
        chkDesconto = new lbframework.bean.checkBox.LBCheckBox();
        txtPorcentagemDesconto = new lbframework.bean.textField.LBTextField();
        lblDiaAtraso = new lbframework.bean.label.LBLabel();
        lblDiaAdiantamento = new lbframework.bean.label.LBLabel();
        lblAte = new lbframework.bean.label.LBLabel();
        txtDataDesconto = new lbframework.bean.textField.LBTextField();
        vRPanel4 = new lbframework.bean.panel.LBPanel();
        tblParcelas = new lbframework.bean.tableEx.LBTableEx();
        vRButton3 = new lbframework.bean.button.LBButton();

        vRToolBarPadrao1.setRollover(true);

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameClosing(evt);
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });

        vRToolBarPadrao2.setRollover(true);
        vRToolBarPadrao2.setVisibleBaixar(true);
        vRToolBarPadrao2.setVisibleIncluir(true);
        vRToolBarPadrao2.setVisibleSalvar(true);

        vRLabel1.setText("Data");

        vRLabel2.setText("Data Vencimento");

        vRLabel3.setText("Descrição");

        vRLabel4.setText("Valor");

        vRLabel5.setText("Situação");

        txtDataLancamento.setEnabled(false);
        txtDataLancamento.setMascara("Data");

        txtDataVencimento.setMascara("Data");
        txtDataVencimento.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtDataVencimentoFocusLost(evt);
            }
        });

        txtValorDocumento.setMascara("Decimal 2");

        vRLabel6.setText("Numero de Parcelas");

        cboNumeroParcelas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboNumeroParcelasActionPerformed(evt);
            }
        });

        vRLabel7.setText("Parcela");

        txtParcela.setEnabled(false);

        javax.swing.GroupLayout vRPanel1Layout = new javax.swing.GroupLayout(vRPanel1);
        vRPanel1.setLayout(vRPanel1Layout);
        vRPanel1Layout.setHorizontalGroup(
            vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(vRLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(vRPanel1Layout.createSequentialGroup()
                        .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(vRLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtDataLancamento, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(vRLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtDataVencimento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cboNumeroParcelas, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(vRLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtParcela, javax.swing.GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE)
                            .addComponent(vRLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(txtDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, 352, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cboSituacao, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(vRLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(vRLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtValorDocumento, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        vRPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {txtDataLancamento, txtDataVencimento});

        vRPanel1Layout.setVerticalGroup(
            vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(vRPanel1Layout.createSequentialGroup()
                        .addComponent(vRLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cboSituacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(vRLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtValorDocumento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(vRPanel1Layout.createSequentialGroup()
                        .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(cboNumeroParcelas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(txtParcela, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(vRPanel1Layout.createSequentialGroup()
                                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(vRLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(vRLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(26, 26, 26))
                            .addGroup(vRPanel1Layout.createSequentialGroup()
                                .addComponent(vRLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtDataLancamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(vRPanel1Layout.createSequentialGroup()
                                .addComponent(vRLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtDataVencimento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(vRLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(19, Short.MAX_VALUE))
        );

        vRButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/salvar.png"))); // NOI18N
        vRButton1.setText("Salvar");
        vRButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vRButton1ActionPerformed(evt);
            }
        });

        vRButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/sair.png"))); // NOI18N
        vRButton2.setText("Sair");
        vRButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vRButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout vRPanel3Layout = new javax.swing.GroupLayout(vRPanel3);
        vRPanel3.setLayout(vRPanel3Layout);
        vRPanel3Layout.setHorizontalGroup(
            vRPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, vRPanel3Layout.createSequentialGroup()
                .addContainerGap(344, Short.MAX_VALUE)
                .addComponent(vRButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(vRButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        vRPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {vRButton1, vRButton2});

        vRPanel3Layout.setVerticalGroup(
            vRPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(vRButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(vRButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        vRPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Informações Adicionais"));

        chkAtraso.setText("Multa Atraso");
        chkAtraso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkAtrasoActionPerformed(evt);
            }
        });

        chkDesconto.setText("Desconto Pagamento Adiantado");
        chkDesconto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkDescontoActionPerformed(evt);
            }
        });

        lblDiaAtraso.setText("% / Dia");

        lblDiaAdiantamento.setText("%");

        lblAte.setText("Até");

        txtDataDesconto.setMascara("Data");
        txtDataDesconto.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtDataDescontoFocusLost(evt);
            }
        });

        javax.swing.GroupLayout vRPanel2Layout = new javax.swing.GroupLayout(vRPanel2);
        vRPanel2.setLayout(vRPanel2Layout);
        vRPanel2Layout.setHorizontalGroup(
            vRPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(vRPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(chkDesconto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(vRPanel2Layout.createSequentialGroup()
                        .addGroup(vRPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(chkAtraso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtPorcentagemAtraso, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblDiaAtraso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(lblAte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(vRPanel2Layout.createSequentialGroup()
                        .addComponent(txtPorcentagemDesconto, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblDiaAdiantamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(txtDataDesconto, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(39, Short.MAX_VALUE))
        );
        vRPanel2Layout.setVerticalGroup(
            vRPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(chkAtraso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(vRPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPorcentagemAtraso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblDiaAtraso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(chkDesconto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(vRPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPorcentagemDesconto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblDiaAdiantamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblAte, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtDataDesconto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(27, Short.MAX_VALUE))
        );

        vRPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Parcelas"));

        vRButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/dividir.png"))); // NOI18N
        vRButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vRButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout vRPanel4Layout = new javax.swing.GroupLayout(vRPanel4);
        vRPanel4.setLayout(vRPanel4Layout);
        vRPanel4Layout.setHorizontalGroup(
            vRPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, vRPanel4Layout.createSequentialGroup()
                .addGroup(vRPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(tblParcelas, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE)
                    .addComponent(vRButton3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        vRPanel4Layout.setVerticalGroup(
            vRPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel4Layout.createSequentialGroup()
                .addComponent(tblParcelas, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(vRButton3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(19, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(vRToolBarPadrao2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(477, 477, 477))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(vRPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 538, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(vRPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(vRPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(vRPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(vRToolBarPadrao2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(vRPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(vRPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(vRPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(vRPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void chkAtrasoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkAtrasoActionPerformed

        if (chkAtraso.isSelected()) {
            lblDiaAtraso.setEnabled(true);
            txtPorcentagemAtraso.setEnabled(true);
            txtPorcentagemAtraso.setObrigatorio(true);


        } else {
            lblDiaAtraso.setEnabled(false);
            txtPorcentagemAtraso.setEnabled(false);
            txtPorcentagemAtraso.setObrigatorio(false);


        }

    }//GEN-LAST:event_chkAtrasoActionPerformed

    private void chkDescontoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkDescontoActionPerformed

        if (chkDesconto.isSelected()) {
            lblDiaAdiantamento.setEnabled(true);
            txtPorcentagemDesconto.setEnabled(true);
            txtPorcentagemDesconto.setObrigatorio(true);
            lblAte.setEnabled(true);
            txtDataDesconto.setEnabled(true);
            txtDataDesconto.setObrigatorio(true);


        } else {
            lblDiaAdiantamento.setEnabled(false);
            txtPorcentagemDesconto.setEnabled(false);
            txtPorcentagemDesconto.setObrigatorio(false);
            lblAte.setEnabled(false);
            txtDataDesconto.setEnabled(false);
            txtDataDesconto.setObrigatorio(false);
        }

    }//GEN-LAST:event_chkDescontoActionPerformed

    private void cboNumeroParcelasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboNumeroParcelasActionPerformed

        totalParcelas = cboNumeroParcelas.getId();
        txtParcela.setText(parcelaAtual + "/" + totalParcelas);

    }//GEN-LAST:event_cboNumeroParcelasActionPerformed
    private void txtDataVencimentoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtDataVencimentoFocusLost
    }//GEN-LAST:event_txtDataVencimentoFocusLost

    private void vRButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vRButton1ActionPerformed
    }//GEN-LAST:event_vRButton1ActionPerformed

    private void vRButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vRButton2ActionPerformed
        try {
            verificarAlteracaoTela();
            sair();

        } catch (Exception e) {
            Util.exibirMensagemErro(e, getTitle());
        }
    }//GEN-LAST:event_vRButton2ActionPerformed

    private void txtDataDescontoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtDataDescontoFocusLost
        // TODO add your handling code here:
    }//GEN-LAST:event_txtDataDescontoFocusLost

    private void vRButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vRButton3ActionPerformed

        try {
            if (txtDataVencimento.getClipText().equals("")) {
                txtDataVencimento.requestFocusLater();
                throw new LBException("Data de Vencimento não pode estar vazia.");
            } else if (txtValorDocumento.getText().equals("")) {
                txtValorDocumento.requestFocusLater();
                throw new LBException("Valor do Documento não preenchido.");
            } else {
                carregarParcelas();
            }

        } catch (Exception e) {
            Util.exibirMensagemErro(e, getTitle());
        }

    }//GEN-LAST:event_vRButton3ActionPerformed

    private void formInternalFrameClosing(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosing
        try {
            verificarAlteracaoTela();
            sair();

        } catch (Exception e) {
            Util.exibirMensagemErro(e, getTitle());
        }
    }//GEN-LAST:event_formInternalFrameClosing
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private lbframework.bean.comboBox.LBComboBox cboNumeroParcelas;
    private lbframework.bean.comboBox.LBComboBox cboSituacao;
    private lbframework.bean.checkBox.LBCheckBox chkAtraso;
    private lbframework.bean.checkBox.LBCheckBox chkDesconto;
    private lbframework.bean.label.LBLabel lblAte;
    private lbframework.bean.label.LBLabel lblDiaAdiantamento;
    private lbframework.bean.label.LBLabel lblDiaAtraso;
    private lbframework.bean.tableEx.LBTableEx tblParcelas;
    private lbframework.bean.textField.LBTextField txtDataDesconto;
    private lbframework.bean.textField.LBTextField txtDataLancamento;
    private lbframework.bean.textField.LBTextField txtDataVencimento;
    private lbframework.bean.textField.LBTextField txtDescricao;
    private lbframework.bean.textField.LBTextField txtParcela;
    private lbframework.bean.textField.LBTextField txtPorcentagemAtraso;
    private lbframework.bean.textField.LBTextField txtPorcentagemDesconto;
    private lbframework.bean.textField.LBTextField txtValorDocumento;
    private lbframework.bean.button.LBButton vRButton1;
    private lbframework.bean.button.LBButton vRButton2;
    private lbframework.bean.button.LBButton vRButton3;
    private lbframework.bean.label.LBLabel vRLabel1;
    private lbframework.bean.label.LBLabel vRLabel2;
    private lbframework.bean.label.LBLabel vRLabel3;
    private lbframework.bean.label.LBLabel vRLabel4;
    private lbframework.bean.label.LBLabel vRLabel5;
    private lbframework.bean.label.LBLabel vRLabel6;
    private lbframework.bean.label.LBLabel vRLabel7;
    private lbframework.bean.panel.LBPanel vRPanel1;
    private lbframework.bean.panel.LBPanel vRPanel2;
    private lbframework.bean.panel.LBPanel vRPanel3;
    private lbframework.bean.panel.LBPanel vRPanel4;
    private lbframework.bean.toolBarPadrao.LBToolBarPadrao vRToolBarPadrao1;
    private lbframework.bean.toolBarPadrao.LBToolBarPadrao vRToolBarPadrao2;
    // End of variables declaration//GEN-END:variables
}
